<h3 class="widget-name">Edit Salary <small><i class="icon-plus-sign"></i> New Salary</small></h3>
<?php 
if(isset($update)){?>
<div class="alert alert-success">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong><?php echo $update;?></strong>
</div>
<?php }?>
<?= form_open(current_url())?>
<div class="row-fluid">
	<div class="span6">
		
	<table>
  <tr>
    <td width="20%">For</td>
    <td width="40%">
    <select name="user" class="selectpicker">
    <option value="">-- Select User -- </option>
    <?php foreach($users as $user) {?>
    <option value="<?= $user->id?>" 
	
	<?php if($salary['user_id']== $user->id){
		echo 'selected="selected"';
		}
		?>
	
	> <?= $user->username;?> </option>
    <?php }?>
    </select>
	<?= form_error('user')?>
    </td>    
  </tr>
  <tr>
    <td>Basic Pay <small class="text-info">( Per month)</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="salary" id="prependedInput" type="text" placeholder="in ruppes" name="basic_pay" value="<?= $salary['basic_pay']?>">
</div>
 <?= form_error('basic_pay')?>
</td>
    
  </tr>
  <tr>
    <td>Per day <small class="muted">( Total Salary / 30 )</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="per_day span4" id="prependedInput" type="text" placeholder="" name="per_day_salary"  value="<?= $salary['per_day_salary']?>" readonly="readonly" ></div>
  <?= form_error('per_day_salary')?>
  </td>    
  </tr>
  <tr>
  <td>Minimum Working Hour</td>
    <td>
    <div class="input-append">
  
  <input class="min_working_hour span4" id="prependedInput" type="text" placeholder="" name="min_working_hour"  value="<?= $salary['min_working_hour']?>">
  <span class="add-on">Hr.</span></div>
  <?= form_error('min_working_hour')?> 
    </td>     
  </tr>
  <tr>
    <td>Per hour <small class="muted">(   per day / working hour )</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="per_hour span4" id="prependedInput" type="text" placeholder="" name="per_hour_salary"  value="<?= $salary['per_hour_salary']?>"  readonly="readonly"></div>
  <?= form_error('per_hour_salary')?>
  </td>    
  </tr>
  <tr>
    <td>Paid Leave Allowed</td>
    <td><input type="text" class="span3" name="paid_leave" value="<?= $salary['paid_leave']?>"/>
	<?= form_error('paid_leave')?>
	</td>    
  </tr>
  <tr>
    <td>Paid Leave / month</td>
    <td><input type="text" class="span3"  name="per_month_leave" value="<?= $salary['per_month_leave']?>"/>
	<?= form_error('per_month_leave')?>
	</td>    
  </tr>
 
</table>
		
	</div>
	<div class="span6">
		
		<table>
		<tr>
				<td>Travelling Allowances</td>
				<td>
				<div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input id="prependedInput" type="text" placeholder="" name="travelling_allowances"  value="<?= $salary['travelling_allowances']?>" >
  </div>
				</td>
			</tr>
			
			<tr>
				<td>HRA</td>
				<td>
					<div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input id="prependedInput" type="text" placeholder="" name="hra"  value="<?= $salary['hra']?>" >
  </div></td>
			</tr>
			<tr>
				<td>Bank A/C no.</td>
				<td><input type="text" name="bank_ac" value="<?= $salary['bank_ac']?>"/></td>
			</tr>
		
			 <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="Update Salary" class="btn btn-info btn-small" />   
    </td>
    <td>&nbsp;</td>
  </tr>
		</table>
		
	</div>
</div>

</form>

<script type="text/javascript">
$(".salary").change(function() {
	var salary = $(".salary").val();
	
	var per_day = salary / 30;
	var per_hour = 
	$('.per_day').val(per_day);	
	
	if($('.min_working_hour').val())
	{
	$('.per_hour').val($('.per_day').val() / $('.min_working_hour').val())
	}
	
	})
	
/*$(".salary").focus( function () {	
	$('.per_day').val(""); 
	})	*/
	
	$('.min_working_hour').change(function () {
		
		$('.per_hour').val($(".per_day").val() / $('.min_working_hour').val())	
		
		})
		
		$('.per_day').change(function () {
			
			
			})
	
</script>